package com.tjsinfo.tjsoa.mail.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.common.SessionUser;
import com.tjsinfo.tjsoa.mail.bo.ITjsEmailFolderBo;
import com.tjsinfo.tjsoa.mail.bo.ITjsFoldMailBo;
import com.tjsinfo.tjsoa.mail.vo.TjsEmailFolder;
import com.tjsinfo.tjsoa.mail.vo.TjsFoldMail;

/**
 * 查询一个文件夹邮件
 * @author wangxiaowei
 *
 */
public class SelectOneFoldMailAction extends Action{
	private ITjsFoldMailBo tjsFoldMailBo;
	private ITjsEmailFolderBo tjsEmailFolderBo;
	public ITjsFoldMailBo getTjsFoldMailBo() {
		return tjsFoldMailBo;
	}
	public void setTjsFoldMailBo(ITjsFoldMailBo tjsFoldMailBo) {
		this.tjsFoldMailBo = tjsFoldMailBo;
	}
	public ITjsEmailFolderBo getTjsEmailFolderBo() {
		return tjsEmailFolderBo;
	}
	public void setTjsEmailFolderBo(ITjsEmailFolderBo tjsEmailFolderBo) {
		this.tjsEmailFolderBo = tjsEmailFolderBo;
	}
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		try {
			String id = request.getParameter("id");
			TjsFoldMail tjsFoldMail = tjsFoldMailBo.selectOneByIdSUB(id);//文件夹邮件
			if (tjsFoldMail != null) {
				request.setAttribute("foldmail", tjsFoldMail);
				List<TjsEmailFolder> list2 = tjsEmailFolderBo.selectByUserId(SessionUser.getUserId(request));//文件夹
				request.setAttribute("foldlist", list2);
				return mapping.findForward("ok");
			} else {
				return mapping.findForward("error");
			}
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return mapping.findForward("error");
		}
	}
	
}
